Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: schedule management and tab store #1105

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

KevinWu098
Copy link
Member

@KevinWu098 KevinWu098 commented Jan 10, 2025

Summary

This PR refactors two sections of our app: Schedule Management (the tab UI) and TabStore (the global tab store).

Schedule Management

Schedule Management Tabs have been refactored to be largely simpler and require only one component for both desktop and mobile. Tab Content (i.e. Tab Panels) have been refactored into a separate component. No logic has changed here.

Tab Store

Tab Store has also been refactored to largely be simpler. Previously, we would not render the Calendar tab on mobile, as it would be shown on the left hand side. However, this would result in inconsistent and double-logic to handle tab switching across both mobile and desktop.

Now, all tabs are rendered so the index of each (calendar = 0, search = 1, ...) are always consistent. The setter for TabStore now has two variants: setActiveTabValue for setting the value of activeTab via value (number) and setActiveTab for setting the value via a string literal union. setActiveTab will be used in all cases where we programmatically change the tab (e.g. focusMap), and setActiveTabValue will be used for event handlers.

Examples:

    const focusMap = useCallback(() => {
        setActiveTab('map');
    }, [setActiveTab]);
    const onChange = (_event: React.SyntheticEvent, value: number) => {
        setActiveTabValue(value);
    };

Test Plan

  1. Perform these tests on both desktop and mobile
  2. Click on each tab, the correct panel should render as expected
  3. Visit /added, /map, etc. The correct panel should be selected
  4. Use quickSearchForClasses. Search panel should open.
  5. Click the map link in the Section Table Body. The Map panel should open.
  6. Having no signed in user should go to the search
  7. Having a signed in user should go to added on desktop and calendar on mobile.

Issues

Closes #

@KevinWu098 KevinWu098 changed the title feat: refactor schedule management and tab store refactor schedule management and tab store Jan 10, 2025
@KevinWu098 KevinWu098 changed the title refactor schedule management and tab store refactor: schedule management and tab store Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant